package com.mccrea.pattern.factory.simplefactory.pizzastore.order;
import com.mccrea.pattern.factory.simplefactory.pizzastore.pizza.Pizza;
import com.mccrea.pattern.factory.util.InputUtil;


/**
 * @Classname OrderPizza
 * @Description 订购披萨
 * @Date 2021/5/7 0007 17:32
 * @Created by Mccrea_Gao
 */
public class OrderPizza {
    public OrderPizza(SimpleFactory simpleFactory) {
        setSimpleFactory(simpleFactory);
    }

    SimpleFactory simpleFactory;
    Pizza pizza = null;
    public void setSimpleFactory(SimpleFactory simpleFactory) {
        String orderType;
        this.simpleFactory = simpleFactory;
        do {
            orderType = InputUtil.getType();
            pizza = simpleFactory.createPizza(orderType);
            if (null != pizza) {
                pizza.prepare();
                pizza.bake();
                pizza.cut();
                pizza.box();
            } else {
                System.out.println("没有指定的pizza，订购失败");
                break;
            }
        } while (true);
    }
}
